<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../../include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>小豆盒子信息编辑</title>

<link href="${ctx}/resources/media/css/chosen.css" rel="stylesheet"
	type="text/css" />
<link rel="stylesheet" type="text/css"
	href="${ctx}/resources/media/css/bootstrap-wysihtml5.css" />
<link rel="stylesheet" type="text/css"
	href="${ctx}/resources/media/css/select2_metro.css" />
<script type="text/javascript"
	src="${ctx}/resources/media/js/bootstrap-fileupload.js"></script>
<script type="text/javascript"
	src="${ctx}/resources/media/js/chosen.jquery.min.js"></script>
<link rel="stylesheet" type="text/css"
	href="${ctx}/resources/media/css/datetimepicker.css" />
<link rel="stylesheet" href="${ctx}/resources/media/css/dialog.css" />
<link rel="stylesheet" type="text/css"
	href="${ctx}/resources/media/css/bootstrap-fileupload.css" />
<script type="text/javascript"
	src="${ctx}/resources/media/js/bootstrap-fileupload.js"></script>
<link href="${ctx}/resources/media/css/jquery.fancybox.css"
	rel="stylesheet" />

<link href="${ctx}/resources/media/css/chosen.css" rel="stylesheet"
	type="text/css" />

<link rel="shortcut icon"
	href="${ctx}/resources/media/image/favicon.ico" />
</head>
<body>
	<div class="row-fluid profile">
		<div class="span12">
			<!--BEGIN TABS-->
			<div class="tabbable tabbable-custom tabbable-full-width">
				<ul class="nav nav-tabs">
					<li><a href="${ctx}/financing/box">小豆盒子列表</a></li>
					<li class="active"><a href="${ctx}/financing/box/form">小豆盒子编辑</a></li>
				</ul>
				<div class="tab-content">
					<!--end tab-pane-->
					<div class="tab-pane profile-classic row-fluid active" id="tab_1_2">
						<div class="span12">
							<!-- BEGIN SAMPLE FORM PORTLET-->
							<div class="portlet box blue">
								<div class="portlet-title">
									<div class="caption">
										<i class="icon-reorder"></i> <span class="hidden-480">小豆盒子编辑</span>
									</div>
								</div>
								<!-- END SAMPLE FORM PORTLET-->
								<div class="portlet-body form ">
									<form class="form-horizontal" id="form"
										action="${ctx}/financing/box/save" method="post"
										enctype="multipart/form-data">
										<fieldset>
											<input id="id" type="hidden" name="id"
												value="${financialPackage.id }"> <input id="version"
												type="hidden" name="version"
												value="${financialPackage.version }"> <input
												id="interestRateHidden" type="hidden"
												name="interestRateHidden"
												value="${financialPackage.interestRate }"> <input
												id="image1" type="hidden" name="image1"
												value="${financialPackage.image1 }"> <input
												id="image2" type="hidden" name="image2"
												value="${financialPackage.image2 }"> <input
												id="image3" type="hidden" name="image3"
												value="${financialPackage.image3 }">
											<h4 class="form-section">产品信息</h4>
											<div class="row-fluid">
												<div class="span6">
													<div class="control-group">

														<label class="control-label">编号</label>
														<div class="controls">
															<input type="text" id="code" name="code"
																class="m-wrap input-xlarge"
																value="${financialPackage.code }" readonly="readonly">
															<span class="help-inline"></span>
														</div>
													</div>
												</div>
												<div class="span6">
													<div class="control-group">

														<label class="control-label">产品名称</label>
														<div class="controls">
															<input type="text" id="name" name="name"
																class="m-wrap input-xlarge"
																value="${financialPackage.name }" maxlength="40">
															<p class="help-block"></p>
														</div>
													</div>
												</div>
											</div>
											<div class="row-fluid">
												<div class="span6">
													<div class="control-group">

														<label class="control-label">投资期限(月)</label>
														<div class="controls">
															<input type="text" name="term" id="term"
																class="m-wrap input-xlarge"
																value="${financialPackage.term }" readonly="readonly">
															<p class="help-block"></p>
														</div>
													</div>
												</div>
												<div class="span6">
													<div class="control-group">

														<label class="control-label">利率</label>
														<div class="controls">
															<input type="text" name="interestRate" id="interestRate"
																class="m-wrap input-xlarge"
																value="${financialPackage.interestRate }"
																Onchange="checkInterestRate()" maxlength="10"> <span id="msg"
																style="color: red"></span>
															<p class="help-block"></p>
														</div>
													</div>
												</div>
											</div>
											<div class="row-fluid">
												<div class="span6">
													<div class="control-group">

														<label class="control-label">起息日</label>
														<div class="controls">
															<input type="text" name="valueDate" id="valueDate"
																class="m-wrap input-xlarge"
																value="${financialPackage.valueDate }" maxlength="50">
															<p class="help-block"></p>
														</div>
													</div>
												</div>
												<div class="span6">
													<div class="control-group">

														<label class="control-label">收益处理</label>
														<div class="controls">
															<input type="text" name="settlementDate"
																id="settlementDate" class="m-wrap input-xlarge"
																value="${financialPackage.settlementDate }" maxlength="50">
															<p class="help-block"></p>
														</div>
													</div>
												</div>
											</div>

											<div class="row-fluid">
												<div class="span6">
													<div class="control-group">

														<label class="control-label">借款方</label>
														<div class="controls">
															<input type="text" name="borrower" id="borrower"
																class="m-wrap input-xlarge"
																value="${financialPackage.borrower }" maxlength="100">
															<p class="help-block"></p>
														</div>
													</div>
												</div>
												<div class="span6">
													<div class="control-group">

														<label class="control-label">资金用途</label>
														<div class="controls">
															<input type="text" name="purpose" id="purpose"
																class="m-wrap input-xlarge"
																value="${financialPackage.purpose }" maxlength="100">
															<p class="help-block"></p>
														</div>
													</div>
												</div>
											</div>

											<div class="row-fluid">
												<div class="span6">
													<div class="control-group">

														<label class="control-label">协议标题</label>
														<div class="controls">
															<input type="text" name="agreementTitle"
																id="agreementTitle" class="m-wrap input-xlarge"
																value="${financialPackage.agreementTitle }" maxlength="40">
															<p class="help-block"></p>
														</div>
													</div>
												</div>
												<div class="span6">
													<div class="control-group">

														<label class="control-label">协议地址</label>
														<div class="controls">
															<input type="text" name="agreementUrl" id="agreementUrl"
																class="m-wrap input-xlarge"
																value="${financialPackage.agreementUrl }" maxlength="200">
															<p class="help-block"></p>
														</div>
													</div>
												</div>
											</div>
											<div class="row-fluid">
												<div class="span6">
													<div class="control-group">

														<label class="control-label">最小投资金额</label>
														<div class="controls">
															<input type="text" name="minAmount"
																id="minAmount" class="m-wrap input-xlarge"
																value="${financialPackage.minAmount }" maxlength="40">
															<p class="help-block"></p>
														</div>
													</div>
												</div>
											
											</div>

											<div class="row-fluid">
												<div class="control-group" id="fileUpload">


													<label class="control-label" for="input01">产品图片</label>

													<div class="controls">
														<div class="fileupload fileupload-new" id="f1"
															data-provides="fileupload">
															<div class="row-fluid">
																<c:if test="${financialPackage.image1!=null}">
																	<div class="span3">
																		<div class="item">
																			<a class="fancybox-button" data-rel="fancybox-button"
																				title="Photo"
																				href="${imgFtpPath}${financialPackage.image1}">
																				<div class="zoom">
																					<img src="${imgFtpPath}${financialPackage.image1}"
																						alt="Photo" />
																					<div class="zoom-icon"></div>
																				</div>
																			</a>
																		</div>
																	</div>
																</c:if>
															</div>
															<div class="input-append">
																<div class="uneditable-input">
																	<i class="icon-file fileupload-exists"></i><span
																		class="fileupload-preview"></span>
																</div>
																<span class="btn btn-file"> <span
																	class="fileupload-new">选择文件</span> <span
																	class="fileupload-exists">更改</span> <input type="file"
																	name="file1" class="default" accept=".jpeg,.jpg,.png"/>
																</span> <a href="#" class="btn fileupload-exists"
																	data-dismiss="fileupload">移除</a>
															</div>
														</div>
													</div>

													<div class="controls">
														<div class="fileupload fileupload-new" id="f2"
															data-provides="fileupload">
															<div class="row-fluid">
																<c:if test="${financialPackage.image2!=null}">
																	<div class="span3">
																		<div class="item">
																			<a class="fancybox-button" data-rel="fancybox-button"
																				title="Photo"
																				href="${imgFtpPath}${financialPackage.image2}">
																				<div class="zoom">
																					<img src="${imgFtpPath}${financialPackage.image2}"
																						alt="Photo" />
																					<div class="zoom-icon"></div>
																				</div>
																			</a>
																		</div>
																	</div>
																</c:if>
															</div>
															<div class="input-append">
																<div class="uneditable-input">
																	<i class="icon-file fileupload-exists"></i><span
																		class="fileupload-preview"></span>
																</div>
																<span class="btn btn-file"> <span
																	class="fileupload-new">选择文件</span> <span
																	class="fileupload-exists">更改</span> <input type="file"
																	name="file2" class="default" accept=".jpeg,.jpg,.png"/>
																</span> <a href="#" class="btn fileupload-exists"
																	data-dismiss="fileupload">移除</a>
															</div>
														</div>
													</div>

													<div class="controls">
														<div class="fileupload fileupload-new" id="f3"
															data-provides="fileupload">
															<div class="row-fluid">
																<c:if test="${financialPackage.image3!=null}">
																	<div class="span3">
																		<div class="item">
																			<a class="fancybox-button" data-rel="fancybox-button"
																				title="Photo"
																				href="${imgFtpPath}${financialPackage.image3}">
																				<div class="zoom">
																					<img src="${imgFtpPath}${financialPackage.image3}"
																						alt="Photo" />
																					<div class="zoom-icon"></div>
																				</div>
																			</a>
																		</div>
																	</div>
																</c:if>
															</div>
															<div class="input-append">
																<div class="uneditable-input">
																	<i class="icon-file fileupload-exists"></i><span
																		class="fileupload-preview"></span>
																</div>
																<span class="btn btn-file"> <span
																	class="fileupload-new">选择文件</span> <span
																	class="fileupload-exists">更改</span> <input type="file"
																	name="file3" class="default" accept=".jpeg,.jpg,.png"/>
																</span> <a href="#" class="btn fileupload-exists"
																	data-dismiss="fileupload">移除</a>
															</div>
														</div>
													</div>

													<!--<c:if test="${!empty map}">
													<div class="controls" id="fileUpload">
														<c:forEach items="${map}" var="item" varStatus="status">
																<div class="fileupload fileupload-new" id="f1"
																	data-provides="fileupload">
																	<div class="row-fluid">
																		<div class="span3">
																			<div class="item">
																				<a class="fancybox-button"
																					data-rel="fancybox-button" title="Photo"
																					href="${imgFtpPath}${item.value}">
																					<div class="zoom">
																						<img
																							src="${imgFtpPath}${item.value}"
																							alt="Photo" />
																						<div class="zoom-icon"></div>
																					</div>
																				</a>
																			</div>
																		</div>
																	</div>
																	<div class="input-append">
																		<div class="uneditable-input">
																			<i class="icon-file fileupload-exists"></i><span
																				class="fileupload-preview"></span>
																		</div>
																		<span class="btn btn-file"> <span
																			class="fileupload-new">选择文件</span> <span
																			class="fileupload-exists">更改</span> <input
																			type="file" name="files" class="default" />
																		</span> <a href="#" class="btn fileupload-exists"
																			data-dismiss="fileupload">移除</a>
																		 <a class="btn"onclick="addItem()"><i class="icon-plus"></i> 新增</a> 
																	</div>
																</div>
														</c:forEach>
														</div>
													</c:if>-->
												</div>
											</div>

											<div class="row-fluid">
												<div class="control-group">

													<label class="control-label" for="input01">产品说明</label>
													<div class="controls">
														<textarea class="wysihtml5 m-wrap" style="width: 1100px"
															name="description" id="description" rows="6">${financialPackage.description }</textarea>
														<p class="help-block"></p>
													</div>
												</div>
											</div>
											<div class="row-fluid">
												<div class="control-group">

													<label class="control-label" for="input01">风控信息描述</label>
													<div class="controls">
														<textarea class="wysihtml5 m-wrap" style="width: 1100px"
															name="riskControlDescription" id="riskControlDescription"
															rows="6">${financialPackage.riskControlDescription }</textarea>
														<p class="help-block"></p>
													</div>
												</div>
											</div>
										</fieldset>
										<div class="form-actions">
											<button type="submit" class="btn blue ibtsubmit">
												<i class="icon-ok"></i> 保存
											</button>
											<button type="button" onclick="history.go(-1)" class="btn">取消</button>
										</div>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!--END TABS-->
			</div>
		</div>
	</div>
	<script type="text/javascript"
		src="${ctx}/resources/media/js/jquery.dataTables.js"></script>
	<script type="text/javascript"
		src="${ctx}/resources/media/js/DT_bootstrap.js"></script>
	<script type="text/javascript"
		src="${ctx}/resources/media/js/select2.min.js"></script>
	<script type="text/javascript"
		src="${ctx}/resources/media/js/wysihtml5-0.3.0.js"></script>
	<script type="text/javascript"
		src="${ctx}/resources/media/js/bootstrap-wysihtml5.js"></script>
	<script type="text/javascript"
		src="${ctx}/resources/media/js/bootstrap-datetimepicker.js"></script>
	<script type="text/javascript"
		src="${ctx}/resources/media/js/form-box-validate.js"></script>
	<script type="text/javascript"
		src="${ctx}/resources/media/js/jquery.validate.min.js"></script>
	<script src="${ctx}/resources/media/js/jquery.fancybox.pack.js"></script>

	<script type="text/javascript"
		src="${ctx}/resources/media/js/chosen.jquery.min.js"></script>
	<script src="${ctx}/resources/media/js/app.js"></script>

	<script src="${ctx}/resources/media/js/gallery.js"></script>
	<script type="text/javascript">
		var dt;
		var count = 1;
		$(function() {
			$("select").select2();

			FormBoxValidate.init();
			Gallery.init();
			//FormFileUpload.init('${ctx}');

			if ($('.wysihtml5').size() > 0) {
				$('.wysihtml5').wysihtml5({});
			}

		});

		function addItem() {
			count++;
			var divId = "f" + count;
			var btnId = "b" + count;
			var html = "<div class='fileupload fileupload-new' data-provides='fileupload' id='"+divId+"'>"
					+ "<div class='input-append'><div class='uneditable-input'><i class='icon-file fileupload-exists'>"
					+ "</i> <span class='fileupload-preview'></span></div><span class='btn btn-file'><span class='fileupload-new'>选择文件</span>"
					+ "<span class='fileupload-exists'>更改</span> <input type='file' name='files' class='default' />"
					+ "</span> <a href=''#' class='btn fileupload-exists' data-dismiss='fileupload'>移除</a>"
					+ "<a id='"+btnId+"' class='btn'><i class='icon-trash'></i> 删除</a></div></div>";
			$("#fileUpload").append(html).find("#" + btnId).click(function() {
				$("#" + divId).remove();
			});
		}

		function checkInterestRate() {
			$("#msg").text("");
			var id = $("#id").val();
			var interestRateBefore = $("#interestRateHidden").val();
			var interestRateAfter = $("#interestRate").val();
			var termVal = $("#term").val();
			if (interestRateBefore == interestRateAfter) {
				return;
			} else {
				$.post("${ctx}/financing/box/interestRate/" + id, {
					term : termVal
				}, function(result) {
					if (!result) {
						$("#msg").text("当前产品正在售卖中，利率无法更改");
					}
				}, "json")
			}
		}

		function search() {
			dt.fnFilter($("#term").val());
			var term = $("#term").val();
			$.post("${ctx}/financing/xiaodou/rate/" + term, null, function(
					result) {
				if (result.success) {
					$("#minProfitRate").val(result.rate);
				}
			}, "json")
		}
		var loanIds = '';
		function sumAmt() {
			var amt = 0.00;
			$("input:checked").each(function() {
				amt += Number($("#amt_" + $(this).val()).val());
			});
			loanIds = ''
			$("#amount").val(amt);
			$("input:checked").each(function() {
				loanIds += $(this).val() + ",";
			});
		}
	</script>


</body>
</html>